package com.wen.service.impl;

import com.github.pagehelper.PageHelper;
import com.wen.dao.ProductMapper;
import com.wen.pojo.Product;
import com.wen.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author 20212
 * ProductServiceImpl servie实现类
 */
@Service
@Transactional
public class ProductServiceImpl implements ProductService {
    @Autowired
    private ProductMapper productMapper;

    @Override
    public List<Product> findAll(int page, int size) throws Exception {
        PageHelper.startPage(page, size);
        return productMapper.findAll();
    }

    @Override
    public int add(Product product) throws Exception {
        return productMapper.add(product);
    }

    @Override
    public int deleteById(int id) throws Exception {
        return productMapper.deleteById(id);
    }

    @Override
    public Product findById(int id) throws Exception {
        return productMapper.findById(id);
    }

    @Override
    public int updateById(Product product) throws Exception {
        return productMapper.updateById(product);
    }
}
